home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: August 14, 1996
- //
- // Description:
- // This is a helper script to perfrom the copyKey command
- // using the various options that have been set
- //
- // Input Arguments:
- // int action 0 - just execute the command
- // 1 - show the option box dialog
- // 2 - return the drag command
- //
- // Return Value:
- // None.
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- keySetOptionBoxCommon( { "copyKey",
- "unknown",
- "setOptionVars",
- $forceFactorySettings } );
-
- // -options
- //
- if ($forceFactorySettings || !`optionVar -exists copyKeyOption`) {
- optionVar -stringValue copyKeyOption "keys";
- }
- // help images
- //
- if ($forceFactorySettings || !`optionVar -exists copyKeyHelpPictures`) {
- optionVar -intValue copyKeyHelpPictures 0;
- }
- }
-
- global proc copyKeySetup (string $parent, string $selectionConnection, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars ($forceFactorySettings);
-
- setParent $parent;
-
- keySetOptionBoxCommon( { "copyKey", $selectionConnection, "setup" } );
-
- // -option
- //
- string $option = `optionVar -query copyKeyOption`;
- if ($option == "keys") {
- radioButtonGrp
- -edit
- -select 1
- method;
- }
- else {
- radioButtonGrp
- -edit
- -select 2
- method;
- }
-
- // help images
- //
- int $pictures = `optionVar -q copyKeyHelpPictures`;
- checkBoxGrp -e -value1 $pictures helpPictures;
-
- // Now get all the dependent widgets in the right
- // enabled/disabled/collapsed/expanded state
- //
- copyKeyWidgetsEnable ($selectionConnection);
- copyKeyHelpPictures;
- }
-
- global proc copyKeyCallback(string $parent, int $doIt,
- string $selectionConnection,
- int $fromGraphEditor,
- int $performAction )
- {
- setParent $parent;
-
- keySetOptionBoxCommon( { "copyKey", $selectionConnection, "callback" } );
-
- // -option
- string $option;
- if (`radioButtonGrp -query -select method` == 1) {
- $option = "keys";
- }
- else {
- $option = "curve";
- }
- optionVar -stringValue copyKeyOption $option;
-
- // help
- //
- int $pictures = `checkBoxGrp -query -value1 helpPictures`;
- optionVar -intValue copyKeyHelpPictures $pictures;
-
- if( $doIt ) {
- string $args[] = { (string) $performAction,
- $selectionConnection,
- (string) $fromGraphEditor };
-
- performCopyKeyArgList 1 $args;
- string $tmpCmd = "performCopyKeyArgList 1 {\"" + $performAction + "\", \"";
- $tmpCmd += $selectionConnection + "\", \"";
- $tmpCmd += $fromGraphEditor + "\"}";
- addToRecentCommandQueue $tmpCmd "Copy Keys";
- }
- }
-
- global proc copyKeyHelpPictures ()
- {
- int $doPictures = `checkBoxGrp -q -value1 helpPictures`;
- if( $doPictures == 0 ) {
- frameLayout -e -collapse yes methodPictureFrame;
- return;
- }
-
- int $method = `radioButtonGrp -q -select method`;
-
- string $methodPicture;
-
- if( $method == 1 ) {
- $methodPicture = "CCPkeyframesOnly.xpm";
- } else {
- $methodPicture = "CCPcurveExact.xpm";
- }
-
- picture -e -image $methodPicture methodPicture;
- frameLayout -e -collapse no methodPictureFrame;
- }
-
- global proc copyKeyDoSelectionChanged (string $selectionConnection)
- //
- // Description:
- // Since timeRange is irrelevant when there are
- // picked keyframes, collapse the timeRangeFrame
- // when there are. (This is hooked in to a SelectionChanged
- // trigger.)
- //
- {
- keySetOptionBoxCommon( { "copyKey", $selectionConnection, "selectionChanged" } );
-
- if( `keyframe -q -sl -kc` > 0) {
- radioButtonGrp -e -enable2 false -select 1 method;
- } else {
- // Only enable the radioButtonGrp if the frame is enabled, otherwise
- // this proc will interfere with the copyKeyWidgetsEnable proc
- //
- if (`frameLayout -q -enable optionsFrame` == 1) {
- radioButtonGrp -e -enable2 true method;
- }
- }
- }
-
-
- global proc copyKeyWidgetsEnable (string $selectionConnection)
- //
- // Description:
- // These are the widgets that get enabled and
- // disabled based on the certain states. Put them
- // here so they're all in one place.
- //
- {
- keySetOptionBoxCommon( { "copyKey", $selectionConnection, "enable" } );
-
- // Options frame
- //
- int $enableIt = ( `radioButtonGrp -q -select timeRange` != 1 );
- frameLayout -e -enable $enableIt optionsFrame;
- }
-
- proc string copyKeyWidgets( string $tabLayout, string $selectionConnection, int $fromGraphEditor )
- {
- global int $gOptionBoxTextColumnWidthIndex;
-
- setParent $tabLayout;
-
- string $tabForm = `columnLayout -adjustableColumn true`;
-
- keySetOptionBoxCommon( { "copyKey", $selectionConnection, "widgets", $fromGraphEditor } );
-
- frameLayout -bv no -lv no -collapsable no optionsFrame;
- columnLayout -adjustableColumn true;
-
- checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 ""
- -cc1 "copyKeyHelpPictures;"
- helpPictures;
-
- radioButtonGrp -numberOfRadioButtons 2 -label "Method"
- -label1 "Keys" -cc1 "copyKeyHelpPictures"
- -label2 "Segments" -cc2 "copyKeyHelpPictures" method;
-
- frameLayout -bv no -lv no -collapsable yes -collapse yes
- methodPictureFrame;
-
- columnLayout -columnAttach "left"
- $gOptionBoxTextColumnWidthIndex;
-
- picture methodPicture;
-
- setParent ..;
- setParent ..;
-
- setParent ..;
-
- setParent ..;
-
- return $tabForm;
- }
-
- proc copyKeyOptions( string $selectionConnection, int $performAction, int $fromGraphEditor )
- {
- // Customisation options
- //
- // Name of the command for this option box (think of it as the base class)
- string $commandName = "copyKey";
- // Title for the option box window
- string $optionBoxTitle = "Copy Keys Options";
- // Title for the apply button
- string $applyTitle = "Copy keys";
-
- // Build the option box "methods"
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Build the window, with a tab layout
- //
- string $widgetList[] = `getStandardWindow $optionBoxTitle 0 "noOptions"`;
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Make the form invisible while we create the widgets in the window
- //
- formLayout -e -vis false $widgetList[1];
-
- // Attach the widgets. No tab layout needed.
- //
- copyKeyWidgets $widgetList[2] $selectionConnection $fromGraphEditor;
-
- // Attach the standard buttons
- //
- string $buttonList[] = `addStandardButtons $commandName $applyTitle
- $widgetList[1] $widgetList[2] "noOptions"`;
-
- // attach commands to the standard buttons
- //
- // Save
- //
- button -e -c ($callback + " " + $widgetList[0] + " false \"\" " +
- $fromGraphEditor + " " + $performAction +
- "; hideOptionBox()") $buttonList[3];
-
- // Close
- //
- button -edit -command hideOptionBox $buttonList[2];
-
- // Reset
- //
- button -edit -command ($setup + " " + $widgetList[0] + " " + $selectionConnection + " true")
- $buttonList[1];
-
- // DoIt
- //
- button -edit -command ($callback + " " + $widgetList[0] + " true \"" +
- $selectionConnection + "\" " + $fromGraphEditor +
- " " + $performAction) $buttonList[0];
-
- // Make the form layout visible so we can see what we built, and
- // reset the template
- //
- formLayout -e -vis true $widgetList[1];
- setUITemplate -popTemplate;
-
- // Customize the 'Help' menu item text.
- // This is called from 3 different places so look at the selection
- // connection to try to figure out which one.
- //
- if (match ("graphEditor", $selectionConnection) != "") {
- setOptionBoxHelpTag( "GraphCopy" );
- } else if (match ("dopeSheet", $selectionConnection) != "") {
- setOptionBoxHelpTag( "DopeCopy" );
- } else {
- setOptionBoxHelpTag( "KeysCopyKeys" );
- }
-
- // Call the setup "method" to fill in the current settings
- //
- eval (($setup + " " + $widgetList[0] + " " + $selectionConnection + " false"));
- showOptionBox();
- showWindow $widgetList[0];
-
- if( $fromGraphEditor ) {
- copyKeyDoSelectionChanged($selectionConnection);
- scriptJob -protected
- -event "SelectionChanged" ("copyKeyDoSelectionChanged " + $selectionConnection)
- -parent $widgetList[2];
- }
- }
-
- proc string assembleCmd( string $selectionConnection,
- int $fromGraphEditor,
- string $options )
- {
- // doCopyKeyArgList takes a string array
- //
- string $cmd = "doCopyKeyArgList 3 { " +
- "\"" + `optionVar -q copyKeyWhichRange` + "\"" +
- ",\"" + `optionVar -q copyKeyRange` + "\"" +
- ",\"" + `optionVar -q copyKeyOption` + "\"" +
- ",\"" + `optionVar -q copyKeyHierarchy` + "\"" +
- ",\"" + `optionVar -q copyKeyControlPoints` + "\"" +
- ",\"" + `optionVar -q copyKeyShapes` + "\"" +
- ",\"" + `optionVar -q copyKeyUseChannelBox` + "\"" +
- ",\"" + $selectionConnection + "\"" +
- ",\"" + $options + "\"" +
- ",\"" + $fromGraphEditor + "\"" +
- ",\"" + `optionVar -q copyKeyDriven` + "\"" +
- " };";
-
- return $cmd;
- }
-
- global proc string performCopyKeyArgList (string $version, string $args[])
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $action, $selectionConnection, $fromGraphEditor
- //
- // $args
- // Version 1
- // [0] $action 0 - do the command
- // 1 - show the option box
- // 2 - return the drag command
- // 3 - do the command (bufferCurve version)
- // 4 - show the option box (bufferCurve version)
- // 5 - return the drag command (bufferCurve version)
- // [1] $selectionConnection name of selection connection to use
- // unless $options has "bufferCurve" in which
- // case this is the name of the editor
- // [2] $fromGraphEditor true if being called from the graph editor
- //
- // Return Value:
- // The actual command to execute.
- //
- {
- int $versionNum = $version;
-
- int $action = $args[0];
- string $selectionConnection = $args[1];
- int $fromGraphEditor = $args[2];
-
- string $cmd = "";
-
- switch( $action ) {
- case 0:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "noOptions" );
- eval( $cmd );
- break;
- case 1:
- copyKeyOptions( $selectionConnection, 0, $fromGraphEditor );
- break;
- case 2:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "noOptions" );
- break;
- case 3:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "bufferCurve" );
- eval( $cmd );
- break;
- case 4:
- copyKeyOptions( $selectionConnection, 3, $fromGraphEditor );
- break;
- case 5:
- setOptionVars( false );
- $cmd = assembleCmd( $selectionConnection, $fromGraphEditor,
- "bufferCurve" );
- break;
- }
- return ($cmd);
- }
-